package com.ruoyi.swla2.service.impl;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONWriter;
import com.ruoyi.swla2.domain.BalanceFix;
import com.ruoyi.swla2.mapper.BalanceFixMapper;
import com.ruoyi.swla2.service.IBalanceFixService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 分区水平衡修正Service业务层处理
 *
 * @author gdqt
 * @date 2023-06-21
 */
@Service
public class BalanceFixServiceImpl implements IBalanceFixService {
    @Autowired
    private BalanceFixMapper balanceFixMapper;

    /**
     * 查询分区水平衡修正
     *
     * @param ID 分区水平衡修正主键
     * @return 分区水平衡修正
     */
    @Override
    public BalanceFix selectBalanceFixByID(Long ID) {
        return balanceFixMapper.selectBalanceFixByID(ID);
    }

    /**
     * 查询分区水平衡修正列表
     *
     * @param balanceFix 分区水平衡修正
     * @return 分区水平衡修正
     */
    @Override
    public List<BalanceFix> selectBalanceFixList(BalanceFix balanceFix) {
        return balanceFixMapper.selectBalanceFixList(balanceFix);
    }

    /**
     * 新增分区水平衡修正
     *
     * @param balanceFix 分区水平衡修正
     * @return 结果
     */
    @Override
    public int insertBalanceFix(BalanceFix balanceFix) {
        return balanceFixMapper.insertBalanceFix(balanceFix);
    }

    /**
     * 修改分区水平衡修正
     *
     * @param balanceFix 分区水平衡修正
     * @return 结果
     */
    @Override
    public int updateBalanceFix(BalanceFix balanceFix) {
        return balanceFixMapper.updateBalanceFix(balanceFix);
    }

    /**
     * 批量删除分区水平衡修正
     *
     * @param IDs 需要删除的分区水平衡修正主键
     * @return 结果
     */
    @Override
    public int deleteBalanceFixByIDs(Long[] IDs) {
        return balanceFixMapper.deleteBalanceFixByIDs(IDs);
    }

    /**
     * 删除分区水平衡修正信息
     *
     * @param ID 分区水平衡修正主键
     * @return 结果
     */
    @Override
    public int deleteBalanceFixByID(Long ID) {
        return balanceFixMapper.deleteBalanceFixByID(ID);
    }

    @Override
    public BalanceFix getZoneWaterBalance(BalanceFix balanceFix) {
        return balanceFixMapper.getZoneWaterBalance(balanceFix);
    }

    @Override
    public void doCalculateZoneWaterBalanceFix(BalanceFix balanceFix) {
        System.out.println(JSON.toJSONString(balanceFix, JSONWriter.Feature.PrettyFormat));
        balanceFixMapper.doCalculateZoneWaterBalanceFix(balanceFix);
    }
}
